package com.midian.common.init;

import java.util.Map.Entry;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;
import org.springframework.scheduling.quartz.CronTriggerBean;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.midian.common.exception.BizException;
import com.midian.common.job.QuarzJobHelper;
import com.midian.common.system.SysStatic;
import com.midian.common.utils.FUtil;
import com.midian.model.sys.SysConf;
import com.midian.service.sys.ISysConfService;

/**
 * 
 * @Title:初始化 
 * @Desription:web系统初始化，初始化前台系统所需的常量，放入Application中
 * @Company:MDKG
 * @ClassName:InitServlet.java
 * @Author:zhucong
 * @CreateDate:2013-6-7 下午5:57:06  
 * @UpdateUser:zhucong  
 * @Version:0.1
 */
public class InitServlet extends HttpServlet{
	
	private static final long serialVersionUID = -6541168966552938103L;
	
	private static final Logger LOG = Logger.getLogger(InitServlet.class);
	
	@Override
	public void init(ServletConfig config) throws ServletException {
		ServletContext sc = config.getServletContext();
		//设置项目根目录到Application作用域
		String path = sc.getContextPath();
		//设置项目根目录到全局变量中
		SysStatic.webRootPath = path;
		sc.setAttribute("path", SysStatic.webRootPath);
		
		//加载权限大模块
		sc.setAttribute("MODELMAP", SysStatic.MODELMAP);
		//前端服务器文件获取地址（指定文本编辑器的图片路径。如果不通过这种方式指定，会造成后台服务器停止后，导致前端获取文本编辑器所编辑的图片内容失败）
		sc.setAttribute("FRONT_SERVER_IP","http://mengzhu.oss-cn-shenzhen.aliyuncs.com/");
		//120.55.150.51
		//获取Spring的ApplicationContext对象
		//WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(sc);
	}
}
